
function checkInput() {
    var tnameTf = document.getElementById('nameTf');
    var tpasswordTf = document.getElementById('passwordTf');
    var trePasswordTf = document.getElementById('rePasswordTf');
    var tmailTf = document.getElementById('mailTf');
    var tphoneTf = document.getElementById('phoneTf');

    inputOnblur(tnameTf);
    inputOnblur(tpasswordTf);
    inputOnblur(trePasswordTf);
    inputOnblur(tmailTf);
    inputOnblur(tphoneTf);

    return false;
}

function inputOnFocus(inputTf) {

    var tTipName = document.getElementById('inputTipName');
    var tTipPwd = document.getElementById('inputTipPwd');
    var treTipPwd = document.getElementById('inputTipRepwd');
    var tTipMail = document.getElementById('inputTipMail');
    var tTipPhone = document.getElementById('inputTipPhone');
    var tOnFocusTips = '必填, 长度为4~16个字符';

    console.log("inputOnFocus " + inputTf + "name " + inputTf.name);
    if (inputTf.id == 'nameTf') {
        tTipName.style.display = 'block';
        tTipName.innerText = tOnFocusTips;
        tTipName.style.color = 'black';
    }
    else if (inputTf.id == 'passwordTf'){
        tTipPwd.style.display = 'block';
        tTipPwd.innerText = tOnFocusTips;
        tTipPwd.style.color = 'black';
    }
    else if (inputTf.id == 'rePasswordTf'){
        treTipPwd.style.display = 'block';
        treTipPwd.innerText = tOnFocusTips;
        treTipPwd.style.color = 'black';
    }
    else if (inputTf.id == 'mailTf'){
        tTipMail.style.display = 'block';
        tTipMail.innerText = tOnFocusTips;
        tTipMail.style.color = 'black';
    }
    else if (inputTf.id == 'phoneTf'){
        tTipPhone.style.display = 'block';
        tTipPhone.innerText = tOnFocusTips;
        tTipPhone.style.color = 'black';
    }
    inputTf.style.border = '1px solid blue';
}

function inputOnblur(inputTf) {
    var tTipName = document.getElementById('inputTipName');
    var tTipPwd = document.getElementById('inputTipPwd');
    var treTipPwd = document.getElementById('inputTipRepwd');
    var tTipMail = document.getElementById('inputTipMail');
    var tTipPhone = document.getElementById('inputTipPhone');

    var isNormal = false;
    inputTf.style.border = '1px solid red';
    if (inputTf.value.length > 3 && inputTf.value.length < 17){
        isNormal = true;
        inputTf.style.border = '1px solid green';
    }

    if (inputTf.id == 'nameTf') {
        tTipName.style.display = 'block';
        if (isNormal){
            tTipName.innerText = '名称输入正确';
            tTipName.style.color = 'green';
        }
        else{
            tTipName.innerText = '名称格式错误';
            tTipName.style.color = 'red';
        }
    }
    else if (inputTf.id == 'passwordTf'){
        tTipPwd.style.display = 'block';
        if (isNormal){
            tTipPwd.innerText = '密码输入正确';
            tTipPwd.style.color = 'green';
        }
        else{
            tTipPwd.innerText = '密码格式错误';
            tTipPwd.style.color = 'red';
        }
    }
    else if (inputTf.id == 'rePasswordTf'){
        treTipPwd.style.display = 'block';
        if (isNormal){
            treTipPwd.innerText = '二次密码输入正确';
            treTipPwd.style.color = 'green';
        }
        else{
            treTipPwd.innerText = '二次密码格式错误';
            treTipPwd.style.color = 'red';
        }
    }
    else if (inputTf.id == 'mailTf'){
        tTipMail.style.display = 'block';
        if (isNormal){
            tTipMail.innerText = '邮箱输入正确';
            tTipMail.style.color = 'green';
        }
        else{
            tTipMail.innerText = '邮箱格式错误';
            tTipMail.style.color = 'red';
        }
    }
    else if (inputTf.id == 'phoneTf'){
        tTipPhone.style.display = 'block';
        if (isNormal){
            tTipPhone.innerText = '手机号输入正确';
            tTipPhone.style.color = 'green';
        }
        else{
            tTipPhone.innerText = '手机号格式错误';
            tTipPhone.style.color = 'red';
        }
    }
    

}